home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 1 / Amiga Tools.iso / wb-tools / toolmanager / source / library / hotkey.c < prev    next >
C/C++ Source or Header  |  1994-06-06  |  3KB  |  137 lines

  1. /*
  2.  * hotkey.c  V2.1
  3.  *
  4.  * Replacement for amiga.lib/HotKey(), fixes a bug in ParseIX()
  5.  *
  6.  * (c) 1990-1993 Stefan Becker
  7.  */
  8.  
  9. #include "ToolManagerLib.h"
  10.  
  11. /* #define this constant to use a modified Hotkey() code, which tries to  */
  12. /* circumvent a bug in commodities.library/ParseIX() V37 (and early V38). */
  13. /* Otherwise the normal HotKey() code is used...                          */
  14. #undef PATCH_V37_MOUSEQUALIFIER_BUG
  15.  
  16. #ifdef PATCH_V37_MOUSEQUALIFIER_BUG
  17.  
  18. /* Modified HotKey() code */
  19. CxObj *HotKey(UBYTE *desc, struct MsgPort *mp, long ID)
  20. {
  21.  struct InputXpression ix;
  22.  
  23.  /* Set structure version number */
  24.  ix.ix_Version=IX_VERSION;
  25.  
  26.  /* Parse Commodities input description string */
  27.  if (!ParseIX(desc,&ix)) {
  28.   CxObj *filter;
  29.  
  30.   DEBUG_PRINTF("IX Version :   0x%02lx\n",ix.ix_Version);
  31.   DEBUG_PRINTF("Class      :   0x%02lx\n",ix.ix_Class);
  32.   DEBUG_PRINTF("Code       : 0x%04lx\n",ix.ix_Code);
  33.   DEBUG_PRINTF("CodeMask   : 0x%04lx\n",ix.ix_CodeMask);
  34.   DEBUG_PRINTF("Qualifier  : 0x%04lx\n",ix.ix_Qualifier);
  35.   DEBUG_PRINTF("QualMask   : 0x%04lx\n",ix.ix_QualMask);
  36.   DEBUG_PRINTF("QualSame   : 0x%04lx\n",ix.ix_QualSame);
  37.  
  38.   /* Correct bug in ParseIX(): Now mouse button qualifiers work again! */
  39.   ix.ix_QualMask|=ix.ix_Qualifier;
  40.  
  41.   DEBUG_PRINTF("Corrected QualMask: 0x%04lx\n",ix.ix_QualMask);
  42.  
  43.   /* Create dummy filter object */
  44.   if (filter=CxFilter("a")) {
  45.    CxObj *sender;
  46.  
  47.    DEBUG_PRINTF("Filter: 0x%08lx\n",filter);
  48.  
  49.    /* Set filter */
  50.    SetFilterIX(filter,&ix);
  51.  
  52.    DEBUG_PRINTF("Filter set, Error: 0x%08lx\n",CxObjError(filter));
  53.  
  54.    /* Create sender object */
  55.    if (sender=CxSender(mp,ID)) {
  56.     CxObj *translate;
  57.  
  58.     DEBUG_PRINTF("Sender: 0x%08lx\n",sender);
  59.  
  60.     /* Attach sender to filter */
  61.     AttachCxObj(filter,sender);
  62.  
  63.     /* Create a black hole translation object */
  64.     if (translate=CxTranslate(NULL)) {
  65.  
  66.      DEBUG_PRINTF("Translator: 0x%08lx\n",translate);
  67.  
  68.      /* Attach translator to filter */
  69.      AttachCxObj(filter,translate);
  70.  
  71.      DEBUG_PRINTF("Cx Error: 0x%08lx\n",CxObjError(filter));
  72.  
  73.      /* Got a Commodities error? */
  74.      if (!CxObjError(filter))
  75.       /* All OK! */
  76.       return(filter);
  77.     }
  78.    }
  79.  
  80.    /* Delete all CxObjects */
  81.    DeleteCxObjAll(filter);
  82.   }
  83.  }
  84.  
  85.  /* Call failed */
  86.  return(NULL);
  87. }
  88.  
  89. #else
  90.  
  91. /* Original HotKey() code */
  92. CxObj *HotKey(UBYTE *desc, struct MsgPort *mp, long ID)
  93. {
  94.  CxObj *filter;
  95.  
  96.  /* Create dummy filter object */
  97.  if (filter=CxFilter(desc)) {
  98.   CxObj *sender;
  99.  
  100.   DEBUG_PRINTF("Filter: 0x%08lx\n",filter);
  101.  
  102.   /* Create sender object */
  103.   if (sender=CxSender(mp,ID)) {
  104.    CxObj *translate;
  105.  
  106.    DEBUG_PRINTF("Sender: 0x%08lx\n",sender);
  107.  
  108.    /* Attach sender to filter */
  109.    AttachCxObj(filter,sender);
  110.  
  111.    /* Create a black hole translation object */
  112.    if (translate=CxTranslate(NULL)) {
  113.  
  114.     DEBUG_PRINTF("Translator: 0x%08lx\n",translate);
  115.  
  116.     /* Attach translator to filter */
  117.     AttachCxObj(filter,translate);
  118.  
  119.     DEBUG_PRINTF("Cx Error: 0x%08lx\n",CxObjError(filter));
  120.  
  121.     /* Got a Commodities error? */
  122.     if (!CxObjError(filter))
  123.      /* All OK! */
  124.      return(filter);
  125.    }
  126.   }
  127.  
  128.   /* Delete all CxObjects */
  129.   DeleteCxObjAll(filter);
  130.  }
  131.  
  132.  /* Call failed */
  133.  return(NULL);
  134. }
  135.  
  136. #endif
  137.